﻿@{
	Layout = "~/Views/Shared/_Layout.cshtml";
}

@using dPet.Application.DataObjects;
@using Hangerd.Utility;

@model ServiceOrderDto

<div class="page-header">
	<h3>服务订单明细 [ 订单号: @Model.OrderNumber ]</h3>
</div>

<div class="panel panel-default">
	<div class="panel-heading">
		<a href="@Url.Action("List", "ServiceOrder", new { status = OrderStatusDto.Init })" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-chevron-left"></span> 返 回</a>
	</div>

	<table class="table table-striped text-center">
		<thead>
			<tr>
				<th class="text-center">服务项名称</th>
				<th class="text-center">选择属性值</th>
				<th class="text-center">服务单价</th>
				<th class="text-center">数量</th>
				<th class="text-center" style="width:200px;">小计（元）</th>
			</tr>
		</thead>
		<tbody>
			@foreach (var orderLine in Model.OrderLines)
			{
				<tr>
					<td>@orderLine.ServiceItemName</td>
					<td>@orderLine.SKUPropertyValueNames</td>
					<td>@orderLine.UnitPrice</td>
					<td>@orderLine.Quantity</td>
					<td>@(orderLine.UnitPrice * orderLine.Quantity)</td>
				</tr>
			}
		</tbody>
		<tfoot>
			<tr>
				<td colspan="4">&nbsp;</td>
				<td>
					<strong>总金额：@Model.TotalAmount 元</strong>
				</td>
			</tr>
		</tfoot>
	</table>
	<div class="panel-footer text-right">
		<button id="btn_cancel_order" type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-minus"></span> 取消订单</button>
		<button id="btn_pay_order" type="button" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-euro"></span> 支付订单</button>
	</div>
	@using (Html.BeginForm("Cancel", "ServiceOrder", FormMethod.Post, new { id = "cancel_serviceorder_form" }))
	{
		<input name="orderId" type="hidden" value="@Model.Id" />
	}
</div>

<div class="modal fade" id="pay_order_Modal" tabindex="-1" role="dialog" aria-labelledby="payOrderModalLabel" aria-hidden="true">
	<br /><br /><br /><br />
	<div class="modal-dialog modal-sm">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="scanModalLabel">选择支付方式</h4>
			</div>
			<div class="modal-body">
				@using (Html.BeginForm("Pay", "ServiceOrder", FormMethod.Post, new { id = "pay_serviceorder_form" }))
				{
					<input name="orderId" type="hidden" value="@Model.Id" />
					<input id="hiddeb_payment_method" name="paymentMethod" type="hidden" value="" />

					<div class="btn-group btn-group-justified">
						<div class="btn-group btn-group-lg">
							<button type="button" class="btn btn-default" onclick="pay_order('@PaymentMethodDto.Cash')">@CommonTools.GetEnumDescription(PaymentMethodDto.Cash)</button>
						</div>
						<div class="btn-group btn-group-lg">
							<button type="button" class="btn btn-default" onclick="pay_order('@PaymentMethodDto.BankCard')">@CommonTools.GetEnumDescription(PaymentMethodDto.BankCard)</button>
						</div>
						<div class="btn-group btn-group-lg">
							<button type="button" class="btn btn-default" onclick="pay_order('@PaymentMethodDto.MembershipCard')">@CommonTools.GetEnumDescription(PaymentMethodDto.MembershipCard)</button>
						</div>
					</div>
				}
			</div>
			<div class="modal-footer">
			</div>
		</div>
	</div>
</div>

@section scripts {
	<script type="text/javascript">
		$(document).ready(function () {
			set_left_nav('#ln_ServiceOrderList');
		});

		$("#btn_pay_order").bind("click", function () {
			$('#pay_order_Modal').modal('show');
		});

		$("#btn_cancel_order").bind("click", function () {
			if (!confirm('确认取消该订单?'))
				return false;

			$("#cancel_serviceorder_form").submit();
		});

		function pay_order(paymentMethod) {
			if (!confirm('确认支付该订单?'))
				return false;

			$("#hiddeb_payment_method").val(paymentMethod);
			$("#pay_serviceorder_form").submit();
		}
	</script>
}